package cn.ldh.service.impl;

import cn.ldh.domain.Product;
import cn.ldh.domain.Store;
import cn.ldh.feignClient.StoreFeignClient;
import cn.ldh.mapper.ProductMapper;
import cn.ldh.service.IProductService;
import cn.ldh.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ProductServiceImpl implements IProductService {

    @Autowired
    private ProductMapper mapper;
    @Autowired
    private StoreFeignClient feignClient;

    @Override
    public JsonResult save(Product product) {
        mapper.add(product);
        Store store = new Store();
        store.setProduct_id(product.getId());
        store.setNumber(product.getNumber());
        JsonResult jsonResult = feignClient.save(store);
        return jsonResult;
    }
}
